package tpju;

/**
 * Write a description of class Composant here.
 * 
 * @author (your name)
 * @version (a version number or a date)
 */
public class Composant {
	private static int cpt_id = 0;
	 
	// instance variables - replace the example below with your own
	private String nomComposant;
	private int id_comp = 0;
	private Voiture MaVoiture;

	/**
	 * Constructor for objects of class Composant
	 */
	public Composant(String n, Voiture v) {
		this.MaVoiture = v;
		// initialise instance variables
		this.nomComposant = n;
		this.id_comp = cpt_id;
		cpt_id++;
		
	}

	/**
	 * 
	 * 
	 * @param y
	 *            a sample parameter for a method
	 * @return the sum of x and y
	 */
	public String getNomComposant() {
		// put your code here
		return this.nomComposant;
	}

	/**
	 * 
	 * 
	 * @param y
	 *            a sample parameter for a method
	 * @return the sum of x and y
	 */
	public void setNomComposant(String nc) {
		// put your code here
		this.nomComposant = nc;

	}

	/**
	 * 
	 * 
	 * @param y
	 *            a sample parameter for a method
	 * @return the sum of x and y
	 */
	public String toString() {
		// put your code here
		return ("Le nom du composant est : " + this.getNomComposant());
	}

	public int getId_comp() {
		return id_comp;
	}


	public Voiture getMaVoiture() {
		return MaVoiture;
	}

	public void setMaVoiture(Voiture maVoiture) {
		this.getMaVoiture().RemoveToListComposant(this);
		MaVoiture = maVoiture;
		maVoiture.addToListComposant(this);
	}
	
	

}
